#!/bin/bash


start=$(date +%s)

cd ./client
# npm i
# /home/work/local/node-v8.11.1-linux-x64/bin/npm install

/home/work/local/node-v10.14.1-linux-x64/bin/npx -p node@10  /home/work/local/node-v10.14.1-linux-x64/bin/npm install

echo "build source"

# npm run testing
# /home/work/local/node-v8.11.1-linux-x64/bin/npm run testing

/home/work/local/node-v10.14.1-linux-x64/bin/npx -p node@10  /home/work/local/node-v10.14.1-linux-x64/bin/npm run testing

echo "client build over"

cd ..

cp -f client/dist/index.html server/src/views/index.ejs
cp -f client/dist/umi.js server/src/statics/umi.js
cp -f client/dist/umi.css server/src/statics/umi.css
cp -rf client/dist/static server/src/statics/

end=$(date +%s)
time=$(( $end - $start ))

echo "build in ($time) 秒"
# 解开注释


start=$(date +%s)

cd server 
npm i

echo "build source"

npm run build

echo "server build over"

cd ..

cp -rf server/* ./

rm -rf server

end=$(date +%s)
time=$(( $end - $start ))

echo "build in ($time) 秒"